/**
 * Created by Administrator on 2017/1/20.
 */
var cookie_token = getCookieValue("token");
console.log(cookie_token);
$('.login-go').click(function () {
    var username = $('#username').val();
    var userpwd = $('#userpwd').val();

    if(username =='' || username == null || username ==undefined){
        layer.msg('用户名不能为空');
    }else
    if(userpwd =='' || userpwd == null || userpwd ==undefined){
        layer.msg('请输入密码');
    }else{
        $.ajax({
            type:'post',
            url:'http://192.168.1.72:8098/api/cft/admin/get/token',
            contentType:'application/json',
            data:JSON.stringify({'account':username,'password':userpwd}),
            dataType:'json',
            success:function (res) {
                if(res.code == '1005'){
                    layer.msg(res.message);
                }else{
                    var admin_token = res.data;
                    setCookie("token",admin_token,24,"/");
                    layer.msg(res.message);
                    location.href='http://localhost:63342/CFT-ADMIN/index.html'
                }
            },
            error:function (res) {
                layer.msg('登陆失败');

            }
        })
    }
});